package com.hdu.dwh.service.impl.cube_impl;

import java.util.Set;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hdu.dwh.enums.Hierachy;
import com.hdu.dwh.mapper.cube_mapper.FilterMapper;
import com.hdu.dwh.pojos.cube_pojos.Filter;
import com.hdu.dwh.service.cube_service.FilterService;

@Service
public class FilterServiceImpl extends ServiceImpl<FilterMapper, Filter> implements FilterService {
    @Override
    public void removeByCubeId(Integer id) {
        Hierachy hierachy = Hierachy.DWS;
        this.lambdaUpdate().eq(Filter::getHierachy, hierachy).eq(Filter::getRelatedId, id).remove();
    }

    @Override
    public Set<Filter> queryFiltersById(Hierachy hierachy, Integer id) {
        return this.lambdaQuery()
            .eq(Filter::getHierachy, hierachy)
            .eq(Filter::getRelatedId, id)
            .list()
            .stream()
            .collect(java.util.stream.Collectors.toSet());
    }

}
